package net.sky.oa.dao.ioffice.impl;


import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import net.sky.oa.model.OffSummUser;
import net.sky.oa.dao.SkyBaseDaoImpl;
import net.sky.oa.dao.ioffice.OffSummUserDao;


@SuppressWarnings("unchecked")
@Repository
public class OffSummUserDaoImpl extends SkyBaseDaoImpl<OffSummUser> implements OffSummUserDao {
	
	public OffSummUserDaoImpl() {
		super.setPersistType(OffSummUser.class);
	}
	
	public List<OffSummUser> findBySummId(Long summId){
		
		return this.findByHql("from OffSummUser su where su.summ.id = ?",new Object[]{summId});
	}

	public void delBySummId(Long id) {
		StringBuilder hql = new StringBuilder("delete from OffSummUser su where su.summ.id = ");
		hql.append(String.valueOf(id));
		Query query=this.getSession().createQuery(hql.toString());
		query.executeUpdate();		
	}

	public List<OffSummUser> findByUserId(Long userId) {
		return this.findByHql("from OffSummUser su where su.rusr.id = ?",new Object[]{userId});
	}
	
	
}
